from rest_framework.pagination import PageNumberPagination
from rest_framework.response import Response

from collections import OrderedDict


class ListInfoPagination(PageNumberPagination):

    def get_paginated_response(self, data):
        return Response(OrderedDict([
            ('is_admin', self.request.user.has_perm('prj005.prj005_all_permissions')),
            ('count', self.page.paginator.count),
            ('next', self.get_next_link()),
            ('previous', self.get_previous_link()),
            ('results', data)
        ]))
